//
//  YBLoveGodNotiCell.m
//  yibeilive
//
//  Created by 南无本师释迦牟尼佛 on 2022/11/18.
//

#import "YBLoveGodNotiCell.h"

@implementation YBLoveGodNotiCell

// 初始化控件
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _bgV = [[UIView alloc]init];
        _bgV.backgroundColor = kUIColorFromRGB(0xE6E6E6);
        _bgV.layer.cornerRadius = 10;
        _bgV.clipsToBounds = YES;
        [self.container addSubview:_bgV];
        
        _noticeImgV = [[UIImageView alloc]init];
        _noticeImgV.image = [UIImage imageNamed:@"msg_chat_cell_love_noti"];
        [self.container addSubview:_noticeImgV];
        
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = kLightGrayColor;
        [self.container addSubview:_lineView];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 0;
        _titleLabel.font = kSystemFont(15);
        _titleLabel.textColor = kBlackColor;
        [self.container addSubview:_titleLabel];
    }
    return self;
}

// 根据 cellData 绘制 cell
- (void)fillWithData:(YBLoveGodNotiCellData *)data {
    [super fillWithData:data];
    
    self.customData = data;
    self.titleLabel.text = data.text;

    self.nameLabel.hidden = YES;
    self.avatarView.hidden = YES;
    self.retryView.hidden = YES;
    [self.indicator stopAnimating];
    [self setNeedsLayout];
}

// 设置控件坐标
- (void)layoutSubviews {
    [super layoutSubviews];

    self.container.mm_center();
    self.bgV.mm_fill();
    self.noticeImgV
        .mm_width(20)
        .mm_height(24)
        .mm_left(self.customData.cellLayout.bubbleInsets.left)
        .mm__centerY(self.container.mm_h/2.0);
    self.lineView
        .mm_width(0.5)
        .mm_left(self.noticeImgV.mm_maxX + 12)
        .mm_top(10)
        .mm_flexToBottom(10);
    self.titleLabel
        .mm_left(self.lineView.mm_maxX + 12)
        .mm_flexToRight(self.customData.cellLayout.bubbleInsets.right)
        .mm_top(self.customData.cellLayout.bubbleInsets.top)
        .mm_flexToBottom(self.customData.cellLayout.bubbleInsets.bottom);
}

@end
